﻿<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>WebAPIProxy Client</Title>
      <Shortcut>webapiproxy</Shortcut>
      <Description>Creates a new client for WebAPIProxy</Description>
      <Author>Fanie Reynders</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal Editable="true">
          <ID>clientName</ID>
          <ToolTip>The API resouce (controller) name</ToolTip>
          <Default>Api</Default>
        </Literal>
        <Literal Editable="true">
          <ID>clientSuffix</ID>
          <ToolTip>Suffix as per config</ToolTip>
          <Default>Client</Default>
        </Literal>
        <Literal Editable="true">
          <ID>method</ID>
          <ToolTip>Http method</ToolTip>
          <Default>Get</Default>
        </Literal>
        <Literal Editable="true">
          <ID>returnType</ID>
          <ToolTip>Return type</ToolTip>
          <Default>object</Default>
        </Literal>
        <Literal Editable="true">
          <ID>useContent</ID>
          <ToolTip>Read the content</ToolTip>
          <Default>//</Default>
        </Literal>
        <Literal Editable="true">
          <ID>parameters</ID>
          <ToolTip>Parameters</ToolTip>
          <Default></Default>
        </Literal>
      </Declarations>
      <Code Language="CSharp">
        <![CDATA[
            using (var client = new $clientName$$clientSuffix$())
            {
                var response = await client.$method$Async($parameters$);
                response.EnsureSuccessStatusCode();
                $useContent$var content = await response.ReadContentAsAsync<$returnType$>();
            }
	    ]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
